Skip to content

feat: add transaction splitting tools#13

Merged
jamiew merged 1 commit into
jamiew:mainfrom
caseypugh:feat/transaction-splits
Jun 15, 2026
Merged

feat: add transaction splitting tools#13
jamiew merged 1 commit into
jamiew:mainfrom
caseypugh:feat/transaction-splits

Conversation

@caseypugh

Copy link
Copy Markdown
Collaborator

Summary

Adds support for transaction splitting by surfacing the community fork's existing split methods as two new MCP tools. Splitting lets a single transaction be divided across multiple categories (e.g. a Target run that's part groceries, part household).

  • get_transaction_splits(transaction_id) (read-only) — returns the current split legs, whether the transaction is split, and each leg's amount/category/merchant/notes.
  • update_transaction_splits(transaction_id, splits) (write, idempotent) — full-replace semantics: the splits you pass become the complete set, replacing any existing ones. Pass an empty list to remove all splits and restore the single un-split transaction.

Inputs use a typed TransactionSplit model (amount + optional category_id, merchant_name, notes), translated into the API's camelCase splitData shape. Monarch validates that leg amounts sum to the parent total; its rejection payload is surfaced as a clear ValueError rather than swallowed. Both tools follow the existing patterns — api_call_with_retry, structured logging, 30s timeout, typed Pydantic structured output.

This brings the tool count from 19 → 21.

Example

Split a -100.00 transaction into groceries and household:

transaction_id="txn_123"
splits=[
    {"amount": -70.00, "category_id": "cat_groceries", "notes": "Food"},
    {"amount": -30.00, "category_id": "cat_household"},
]

Testing

  • New tests/test_splits.py (8 cases): split retrieval, payload translation, merchant defaulting, split removal via empty list, and API-error surfacing.
  • Added both tools to the failure-propagation matrix in test_tool_coverage.py.
  • Updated the tool-count assertion (19 → 21) in test_structured_output.py.
  • Refreshed CLAUDE.md tool/test counts and the fork capability inventory.

uv run python scripts/ci.py — ruff check, ruff format, mypy, and pytest all pass (206 passed, 5 skipped).

Surface the community fork's split methods as two new MCP tools:

- get_transaction_splits(transaction_id): read the current split legs
- update_transaction_splits(transaction_id, splits): full-replace the
  split set; an empty list removes all splits and restores the single
  un-split transaction

Inputs use a typed TransactionSplit model (amount + optional category_id,
merchant_name, notes) and are translated into the API's camelCase
splitData shape. Monarch validates that leg amounts sum to the parent
total and its rejection payload is surfaced as a clear error.

Adds tests/test_splits.py (8 cases) plus coverage-matrix and tool-count
test updates, and refreshes CLAUDE.md tool/test counts.
@jamiew jamiew merged commit a6d1b30 into jamiew:main Jun 15, 2026
5 checks passed
@caseypugh caseypugh deleted the feat/transaction-splits branch June 15, 2026 21:17
jamiew added a commit that referenced this pull request Jun 30, 2026
- transaction splitting tools (#13) and session-dir fix (#12), both from @caseypugh
- dependency refresh and fork-pin bump to 1.4.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants